using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Unity.Services.Authentication;
using Unity.Services.Core;
using Unity.Services.RemoteConfig;
using UnityEngine;

public class InitializeUnityServices : MonoBehaviour
{
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct userAttributes
	{
	}

	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct appAttributes
	{
	}

	private async Task Start()
	{
		await UnityServices.InitializeAsync();
		if (!AuthenticationService.Instance.IsSignedIn)
		{
			await AuthenticationService.Instance.SignInAnonymouslyAsync();
		}
		RemoteConfigService.Instance.FetchCompleted += ApplyRemoteConfig;
		await RemoteConfigService.Instance.FetchConfigsAsync(default(userAttributes), default(appAttributes));
	}

	private void ApplyRemoteConfig(ConfigResponse configResponse)
	{
		if (PlayerPrefs.GetString("urlMoreGameClicked", null) != Config.urlMoreGame)
		{
			MainMenu.Instance.moreGameBtnImg.color = Color.red;
		}
	}
}
